/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-03-08 11:16:14
 * @LastEditTime : 2023-06-27 16:30:41
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\CenterTypeUpdate.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { DataSynchronization } from '../Common/Conversion'

export const CenterTypeUpdate = async ({ url, OptionsEvent, ClientData }) => {
    const centerUuid = await DataSynchronization()
    let data = {
        type: '系统配置',
        pageSize: 10000,
        params: { pageIndex: 1, OrderField: 'tableName@asc' },
        get: API_LIST()['getCenterTypeUpdateListCenterTypes'],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        // exportExcel: true,
        options: [
            <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增同步列表" />,
        ],
        columns: [
            commonTableList.uuid,
            {
                ...commonTableList.tableName,
                title: '表名',
                width: 200,
            },
            {
                dataIndex: 'apiUrl',
                title: 'API地址',
                valueType: 'input',
                rules: true,
                width: 200,
                hideInSearch: true,
            },

            {
                dataIndex: 'centerUuid',
                title: '上传位置',
                valueType: 'select',
                valueEnum: centerUuid,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'pushOrUpdate',
                title: '上传或拉取',
                valueType: 'select',
                valueEnum: {
                    0: '拉取',
                    1: '上传',
                },
                width: 200,
                hideInSearch: true,
            },

            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 220,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" url={url} data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }
    return data
}
